package com.newly.center.business.api;

import com.newly.api.business.feign.DataQueryClient;
import com.newly.center.business.service.CheckRecordService;
import com.newly.common.base.annotation.NewlyLog;
import com.newly.common.base.constants.MenuConstant;
import com.newly.common.base.constants.ServerUriConstant;
import com.newly.common.base.entity.R;
import com.newly.common.base.entity.business.Dto.DataQueryDto;
import com.newly.common.base.entity.business.Po.CheckRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @anthor sbq
 * @date 2021/11/18 15:19
 */
@RestController
@RequestMapping(ServerUriConstant.NEWLY_BUSINESS_QUERY)
public class DataQueryController implements DataQueryClient {

    @Autowired
    private CheckRecordService checkRecordService;

    @Override
    public void export(HttpServletResponse response,DataQueryDto dataQueryDto) {
        checkRecordService.export(response, dataQueryDto);
    }

    @Override
    public R getPage(DataQueryDto dataQueryDto) {
        return R.ok(this.checkRecordService.getPage(dataQueryDto));
    }

    @Override
    public R getDetailsById(Integer id) {
        return R.ok(this.checkRecordService.getDetailsById(id));
    }

    @NewlyLog(ability = MenuConstant.Ability.UPD, title = "数据校验", isOpen = true)
    @Override
    public R audit(CheckRecord checkRecord) {
        this.checkRecordService.audit(checkRecord);
        return R.ok();
    }
}
